package com.huang.core.widget.edittext

import android.text.Editable

open class DecimalLengthChangeListener(
        private val maxCountAfterPoint: Int = 2
) : SimpleTextChangeListener() {
    override fun afterTextChanged(s: Editable) {
        super.afterTextChanged(s)
        //去除最后小数点后x位
        val temp = s.toString()
        val posDot = temp.indexOf(".")
        if (posDot >= 0) {
            if (temp.length - posDot - 1 > maxCountAfterPoint) {
                s.delete(posDot + maxCountAfterPoint+1, posDot +maxCountAfterPoint+ 2)
            }
        }
        afterFilter(s)
    }
    open fun afterFilter(s: Editable){

    }
}